<template>
	<view class="order">
		<view class="order_top">
			<view class="account_info">
				<view class="padding-15">
					<my-s-tabs effect slot-title @change="changeFirst" v-model="activeTab" 
						lineHeight='6' navPerView="3" activeColor="#FF7133" >
						<my-s-tab  v-for="(item, index) of tabList" :key="index">{{ item.name }}</my-s-tab>
					</my-s-tabs>
				</view>
			</view>
		</view>
		<view style="height:80rpx;"></view>
		<view class="order_info" style="margin-bottom: 30rpx;">
			<view class="content" v-if="list.length">
					<view v-for="(item, index) in list" :key="index">
							<view class="top border fs-13">
								<view></view>
								<view>
									{{item.status_text}}
								</view>
							</view>
							<view>
								<view class="flex detail">
									<image class="order_img" :src="item.goods.mimage" mode="aspectFit" />
									<view class="order_oneline">
										<view class="">
											<view class="bold two-line">{{item.goods.name}}</view>
											<view class="fs-13 ">兑换时间：{{($fomartDate(item.createtime)).substr(0,10)}}</view>
										</view>
									</view>
								</view>
							
							</view>
							<view class="order_option" v-if="item.wl_type||item.wl_dh">
								<view>{{item.wl.name}}</view>
								<view>{{item.wl_dh}}</view>
							</view>
				</view>
			</view>
			<view class="bitmap" v-else>
				<image src="../../static/img/no_content.png" mode="aspectFit"></image>
				<view class="gray_font fs-13">
					没有信息哦~
				</view>
			</view>
		</view>
	
	
	</view>
</template>

<script>
	const app = getApp().globalData;
	import passkeyborad from '@/components/yzc-paykeyboard/yzc-paykeyboard.vue'
	const {
		imgRemote,
	} = app;
	export default {
		components: {
			passkeyborad
		},
		data() {
			return {
				imgRemote: imgRemote,
				tabList: [
					{
						name: '全部',
						id: ''
					},
					{
						name: '待发货',
						id: '1'
					},
					
					{
						name: '已发货',
						id: '2'
					}
				],
				activeTab: 0,
				search_default: true,
				list: [],
				page: 1,
				id: '',
				addressInfo: '',
				totalPrice: 0,
				feeInfo: {},
				freight: 0,
				pay_type: 'wxpay',
				orderInfo: '',
				index: '',
				show: false,
				showPay: 0,
				pay_password: '',
				price:'',
				list2:[]
			};
		},
		methods: {
		
			
			fixed(val) {
				return Number(val).toFixed(2);
			},

			//初始订单请求
			orderList(id) {
				let params = {
					token: uni.getStorageSync('userToken'),
					status: id?id:'',
					page: this.page
				};
				this.$get(this.$api.giftLists, params, (res) => {
					let {
						data
					} = res;
					if (data.code == 1) {
					      console.log(data);
						this.list = this.list.concat(data.data.data);
					} else {
						this.$Toast(data.msg);
					}

				}, true)
			},
			changeFirst(e) {
				this.page = 1;
				this.list = [];
				this.id = this.tabList[e].id;
				this.orderList(this.id);
			},
		},
		onLoad(e) {
			this.activeTab = e.index ? parseInt(e.index)+parseInt(1) : 0;
			this.id = e.id;
			this.orderList(e.id);
		},
		onReachBottom() {
			this.page++;
			this.orderList(this.id);
		},
		onShow() {
		
			setTimeout(() => {
				let {
					orderIndex
				} = getApp().globalData;
				console.log(orderIndex)
				if (orderIndex) {
					this.list.splice(orderIndex, 1)
				}
			}, 1000)
		},
		onHide() {
			getApp().globalData.orderIndex = null;
		},
		onUnload() {
			getApp().globalData.orderIndex = null;
		}
	};
</script>

<style lang="scss" scoped>
	.order .pay-method {
		padding: 0 20rpx 30rpx;

		.way {
			height: 80rpx;
			line-height: 80rpx;
		}

		.iconfont {
			font-size: 50rpx;
		}

		.submit-order {
			background: #FF7133;
			width: 200rpx;
			color: white;
			text-align: center;
			height: 60rpx;
			border-radius: 10rpx;
			line-height: 60rpx;
			margin: 0 auto;
		}
	}

	.order .select_account {
		border-bottom: 1px solid #efefef;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		height: 65rpx;
		padding-right: 18rpx;
	}

	.order .select_account text {
		color: grey;
		display: inline-block;
		margin-left: 10rpx;
	}

	.order .select_account .uni-icons {
		color: grey !important;
	}

	.order .account_info {
		background: white;
		position: fixed;
		width: 100%;
		z-index: 2;
	}

	.order .s-tabs-nav-wrap .s-tab-nav-view {
		height: 100%;
		display: flex;
		justify-content: space-around;
	}

	.order .order_option {
		border-top: 1px solid #efefef;
		height: 96rpx;
		line-height: 96rpx;
		text-align: right;
		padding:0 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.order .order_option text {
		border-radius: 23rpx;
		width: 140rpx;
		display: inline-block;
		height: 46rpx;
		line-height: 46rpx;
		margin-left: 20rpx;
		font-size: 26rpx;
		text-align: center;
	}

	.order .another_order {
		background: white;
		color: #FF3333;
		border: 1px solid #F33;
	}

	.order .look_logist {
		background: rgb(2, 177, 228);
		color: white;
	}

	.order .cancel_order {
		background: white;
		color: #333;
		border: 1px solid #333;
	}

	.confirm_good {
		background: red;
		color: white;
		// border: 1px solid red;
	}

	.order .order_img {
		width: 208rpx;
		height: 208rpx;
		margin-right: 30rpx;
		border-radius: 10rpx;
	}

	.time {
		padding: 0 30rpx 28rpx;
		margin-top: -46rpx;
	}

	.order .order_info .content>view {
		background: white;
		margin: 30rpx 30rpx 30rpx 30rpx;

		border-radius: 10rpx;
	}

	.order .order_info .content .top {
		padding: 0 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 60rpx;
	}

	.order .order_info .content .detail {
		padding: 20rpx 20rpx 0;
		// border-top: 1px solid #efefef;
	}

	.order .order_statu .mask {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, .5);
	}

	.order .order_statu .operate {
		margin-top: 10rpx;
		padding: 2px 0 0;
		z-index: 9999;
		border-radius: 2px;
		position: fixed;
		right: 20rpx;
		color: $m-c;
		background: #fff;
		width: 25%;
	}

	.order .order_statu .operate>view {
		height: 64rpx;
		line-height: 64rpx;
		text-align: center;
	}

	.order .order_statu .operate .all_order {
		border-bottom: 1px solid #efefef;
	}

	.order .custom-tabs {

		// padding: 0 30rpx;
		/deep/.s-tab-nav-view {
			display: flex;
			justify-content: space-between;
		}

		/deep/ .s-tab-nav {
			padding: 0;
		}
	}

	.order .bitmap {
		text-align: center;
	}

	.order .bitmap image {
		width: 60%;
		height: 500rpx;
		margin: 200rpx 0 0;
	}

	.order .order_oneline {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	/deep/ .s-tabs .s-tab-line {
		bottom: 1rpx;
		border-radius: 10rpx;
	}

	/deep/ .s-tab-nav {
		color: #000;
	}
	.content{
		box-sizing: border-box;
		padding: 0 0 30rpx 0;
	}
</style>
